package cn.spark.study.sql;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.sql.DataFrame;
import org.apache.spark.sql.SQLContext;

/**
 * 手动指定数据源
 *
 * @author jun.zhang6
 * @date 2020/11/15
 */
public class ManuallySpecifyOptions {
    public static void main(String[] args) {
        SparkConf conf = new SparkConf()
                .setAppName("ManuallySpecifyOptions");

        JavaSparkContext sc = new JavaSparkContext(conf);

        SQLContext sqlContext = new SQLContext(sc);

        DataFrame personDF = sqlContext.read().format("json").load("hdfs://ymm1:9000/students.json");

        personDF.select("name").write().format("json").save("hdfs://ymm1:9000/test.json");

        sc.close();
    }
}
